﻿using System;
using System.Collections.Generic;
using System.Text;
using IWshRuntimeLibrary;
using System.IO;
using System.Reflection;
namespace UTIL
{
    public class LnkFileClass
    {

        public static bool CreateLnkFile(String lnkFile, String ExeFilePath, String Description,String Argument,String strExePath)
        {
            try
            {                            
                String CreateDir = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                IWshShell_Class wShell=new IWshShell_Class();
                IWshShortcut shortCut;
                shortCut = wShell.CreateShortcut(CreateDir + @"\" + lnkFile + ".lnk") as IWshShortcut;
                shortCut.TargetPath = ExeFilePath;
                shortCut.WindowStyle = 1;
                shortCut.Description = Description;            
                shortCut.WorkingDirectory = "";
                shortCut.Arguments = Argument;
                //A-2009-09-10 添加图标
                if (strExePath != string.Empty)
                {
                    shortCut.IconLocation = strExePath + ",0";
                }
                //A-2009-09-10
                shortCut.Save();
                wShell = null;
                return true;
            }
            catch (Exception me)
            {
                UTIL.CException.SaveExcepiton(UTIL.ErrorType.Error, me, MethodBase.GetCurrentMethod().GetType());//A-2009-10-11
                return false;
            }
        }
    }
}
